package com.iwhalecloud.bss.kite.cucc.service.attr.linkhandler;

import com.iwhalecloud.bss.kite.common.constant.KeyConsts;
import com.iwhalecloud.bss.kite.common.util.KiteStringUtils;
import com.iwhalecloud.bss.kite.cucc.service.attr.handler.LocalUsersUseAttrHandler;
import com.iwhalecloud.bss.kite.listener.handler.attr.annotation.AttrHandler;
import com.iwhalecloud.bss.kite.listener.handler.attr.impl.AbstractAttrLinkageHandler;
import com.iwhalecloud.bss.kite.manager.inst.KiteAttr;
import com.iwhalecloud.bss.kite.manager.inst.KiteInst;
import com.iwhalecloud.bss.kite.service.attr.AttrData;
import org.springframework.stereotype.Service;

import java.util.Objects;

/**
 * <Description> <br>
 *
 * @author cheng.leizhen01<br>
 * @version 1.0<br>
 * @taskId <br>
 * @CreateDate 2021年3月16日 <br>
 * @since R9.0<br>
 * @see com.iwhalecloud.bss.kite.cucc.service.attr.linkhandler <br>
 */
@Service
@AttrHandler(LocalUsersUseAttrHandler.class)
public class LocalUsersUseAttrLinkHandler extends AbstractAttrLinkageHandler<AttrData> {

    // 	用户用途选择【经营性】时经营许可证号码属性显示且必填
    @Override
    public void handle(KiteAttr attr, KiteInst inst, AttrData data) {
        if (Objects.isNull(attr)) {
            return;
        }
        // 经营许可证号码
        KiteAttr BusinessLicenseNo = inst.getAttr("2_0000198");
        if(KiteStringUtils.equalsAny(attr.getValue(),"1_0000364" )){
             //用户用途选择【经营性】时经营许可证号码属性显示且必填
            BusinessLicenseNo.setShowType(KeyConsts.PROD_ATTR_SHOW_TYPE_M);
            BusinessLicenseNo.setIsNull(KeyConsts.IFTRUE_F);
        }else{
            BusinessLicenseNo.setShowType(KeyConsts.PROD_ATTR_SHOW_TYPE_E);
            BusinessLicenseNo.setIsNull(KeyConsts.IFTRUE_T);
        }
    }

    @Override
    public void handleStyle(KiteAttr attr, KiteInst inst, AttrData data) {

    }

}
